package com.authine.cloudpivot.ext.dto;

import com.authine.cloudpivot.ext.utils.BigDecimalUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@Data
@Schema(description = "ContractClauseDto")
@ApiModel("代购条款表")
public class ContractClauseDto {
    @Schema(description = "代购条款ID")
    private String id;
    @Schema(description = "代购意向ID")
    private String contractIntentionId;
    @Schema(description = "客户订单ID")
    private String customerOrderId;
    @Schema(description = "客户订单ID集合")
    private List<String> customerOrderIds;
    @Schema(description = "条款名称")
    private String name;
    @Schema(description = "条款")
    private String clause;
    @Schema(description = "计划时间", format = "yyyy-MM-dd HH:mm:ss")
    private String planTime;
    @Schema(description = "交付时间", format = "yyyy-MM-dd HH:mm:ss")
    private String deliverTime;
    @Schema(description = "条款比例")
    private BigDecimal clauseRatio;
    @Schema(description = "服务费比例")
    private BigDecimal serviceChargeRatio;
    @Schema(description = "服务费金额")
    private BigDecimal serviceCharge;
    @Schema(description = "描述")
    private String description;
    @Schema(description = "小计")
    private BigDecimal total;
    @Schema(description = "删除")
    private String del;
    @Schema(description = "操作人")
    private String operator;
    @Schema(description = "客户订单状态")
    private String orderCustomerStatus;
    @Schema(description = "pageIndex")
    private Integer pageIndex;
    @Schema(description = "pageSize")
    private Integer pageSize;

    public static Map<String, Object> voToEntity(ContractClauseDto dto) {
        Map<String, Object> result = new HashMap<>();
        result.put("id", dto.getId());
        result.put("contract_intention_id", dto.getContractIntentionId());
        result.put("customer_order_id", dto.getCustomerOrderId());
        result.put("name", dto.getName());
        result.put("clause", dto.getClause());
        result.put("plan_time", dto.getPlanTime());
        result.put("deliver_time", dto.getDeliverTime());
        result.put("clause_ratio", BigDecimalUtils.round(dto.getClauseRatio(), 2));
        result.put("service_charge_ratio", BigDecimalUtils.isNull(dto.getServiceChargeRatio()));
        result.put("service_charge", BigDecimalUtils.isNull(dto.getServiceCharge()));
        result.put("description", dto.getDescription());
        result.put("total", dto.getTotal());
//        result.put("del", !Objects.isNull(dto.getDel())&&dto.getDel().equals("1")?true:false);
        result.put("operator", dto.getOperator());
        return result;
    }
}
